package com.example.aircraftwar2024.music;

import android.content.Context;
import android.media.MediaPlayer;

import com.example.aircraftwar2024.R;

public class MyMediaPlayer {
    private MediaPlayer bgMp;
    private MediaPlayer bgBossMp;
    public MyMediaPlayer(Context context){
        if (bgMp == null){
            bgMp = MediaPlayer.create(context,R.raw.bgm);
            bgMp.setLooping(true);
        }

        if (bgBossMp == null){
            bgBossMp =  MediaPlayer.create(context, R.raw.bgm_boss);
            bgBossMp.setLooping(true);
        }

    }
    public void startBgm(){
        bgBossMp.pause();
        bgMp.start();
    }

    public void startBossBgm(){
        bgBossMp.start();
        bgMp.pause();
    }

    public void stopBgm(){
        if(bgMp != null && bgBossMp.isPlaying()){
            bgMp.stop();
            bgBossMp.release();
            bgMp= null;
        }
    }

    public void stopBossBgm(){
        if(bgBossMp != null && bgMp.isPlaying()){
            bgBossMp.stop();
            bgMp.release();
            bgBossMp= null;
        }
    }
}
